# 输入年、月、日
year = eval(input())
month = eval(input())
day = eval(input())

if month == 2:
    if year % 400 == 0 or year % 100 !=0 and year % 4 == 0: 
        days = 29  # 闰年，2月为29天
    else:
        days = 28  # 平年，2月为28天

elif month in (1,3,5,7,8,10,12):
    days = 31

elif month == 4 or month == 6 or month == 9 or month == 11:
    days = 30

days_left = days - day

# days_left=离月底还有几天
print(days_left)
